package net.zjitc.android2019.ch3storage;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.Nullable;
import android.util.Log;

public class MyHelper extends SQLiteOpenHelper {

    public MyHelper(@Nullable Context context) {
        super(context, "y.db", null, 1);
        Log.v("sqlite","构造方法");
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table user(id integer primary key autoincrement,name varchar(20))";
        db.execSQL(sql);
        Log.v("sqlite","onCreate方法");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql = "alter table user add sex char(5)";
        db.execSQL(sql);
        Log.v("sqlite","onUpgrade方法");

    }
}
